const express = require('express')
const router = express.Router()

router.post('/', () => {
  const str = "你是一名英语老师，批改英语作业，告诉作者哪里不好，哪里可以改进，所有的回复都使用中文";
  const home = `My Dream
Everyone has a dream, and so do I. My dream is to become an accomplished writer and share my ideas with the world.
Since childhood, I have been fascinated by books and the power of words. I spent countless hours reading novels, poems, and essays from various writers, and I was amazed at how they could use language to express their emotions and convey their messages. As I grew older, I started writing stories and essays myself, and I discovered that writing was not only a way to express myself but also a way to connect with others.
Now, as I pursue my dream of becoming a writer, I am faced with challenges and obstacles. Writing is a demanding craft that requires discipline, patience, and creativity. Some days I struggle to find the right words or the right ideas, and other days I face rejection and criticism. But every setback is a lesson, and every challenge is an opportunity to grow.
To achieve my dream, I know I must work hard and never give up. I read extensively and write every day, honing my skills and exploring new styles and genres. I also seek feedback from other writers and readers, learning from their perspectives and insights. And most importantly, I stay true to myself and my vision, always striving to write with authenticity and integrity.
In conclusion, my dream of becoming a writer may seem daunting, but I believe that anything is possible if I work hard and stay committed. With perseverance and passion, I hope to one day create works that inspire, entertain, and enlighten others.`;

  const { Configuration, OpenAIApi } = require("openai")

  const configuration = new Configuration({
    apiKey: '',
  })

  const openai = new OpenAIApi(configuration)

  async function chat() {
    const completion = await openai.createChatCompletion({
      model: "gpt-3.5-turbo",
      messages: [
        { role: "system", content: str },
        { role: "user", content: "你是谁!" },
        { role: "user", content: "请对我接下来输入的内容进行批改" },
        { role: "user", content: home },
      ],
    })
    console.log(completion.data.choices[0].message)
  }
  chat()
})

module.exports = router

